import logging

logging.basicConfig(level=logging.WARNING,    #设置级别，根据等级显示
                    filename='example.log',
                    format="%(asctime)s-[%(filename)s-->line:%(lineno)d]-%(levelname)s:%(message)s") #设置输出格式
logging.debug("This is a debug log")
logging.info("This is a info log")
logging.warning("This is a warning log")
logging.error("This is a error log")
logging.critical("This is a critical log")